// const chalk = require('chalk');
import chalk, {Chalk} from 'chalk';

console.log(chalk.red('Hello world!'));

//多个chalk可以拼接
console.log(chalk.red('Hello world!')+'@'+chalk.blueBright('Hello world!'));

//可以链式调用
console.log(chalk.red.bgGreen.bold('Hello world!'));

//同一个chalk可以进行多个参数的拼接
console.log(chalk.red('hello', 'imooc'));

//chalk中可以嵌套
console.log(chalk.red('hello',chalk.underline.bgBlue('world')+'!'));

//自定义颜色
console.log(chalk.rgb(255, 255, 0).underline('Hello world!'));
//也支持16进制
console.log(chalk.hex('#ffff00').bold('hello world!'));
//改变颜色后不想做额外的操作，就可以直接 `()`
console.log(chalk.hex('#ffff00')('hello', 'world!'));


//常见用法
const error = (...text)=> console.log(chalk.bold.hex('#ff0000')(text));
const warning = (...text)=> console.log(chalk.bold.hex('#ffa500')(text));
error('Error!');
warning('Warning!');


//region 自定义chalk
const customChalk = new Chalk({
  /**
   Specify the color support for Chalk.

   By default, color support is automatically detected based on the environment.

   Levels:
   - `0` - All colors disabled.
   - `1` - Basic 16 colors support.
   - `2` - ANSI 256 colors support.
   - `3` - Truecolor 16 million colors support.
   */
  // readonly level?: ColorSupportLevel;

  // level: 0 //禁用所有颜色
  level: 1
})
console.log(customChalk.blue('Hello world!'));
console.log(customChalk.hex('#ffaa00')('Hello world!'));
//endregion
